package com.bluemson.controller;

import com.bluemson.entity.Article;
import com.bluemson.entity.Plate;
import com.bluemson.service.GetService;
import com.bluemson.service.Impl.GetServiceImpl;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author mac
 */
@Controller
@RequestMapping("/search")
public class SearchController {
    GetService getService = new GetServiceImpl();
    @RequestMapping(value = "/article", method = {RequestMethod.GET})
    @ResponseBody
    public Map searchArticle(@RequestParam("article")String article){
        List<Article> articles = getService.searchArticle(article);
        Map map= new HashMap();
        map.put("msg","这是含该字段的帖子");
        map.put("articles",articles);
        map.put("status",1);
        return map;
    }
    @RequestMapping(value = "/plate", method = {RequestMethod.GET})
    @ResponseBody
    public Map searchPlate(@RequestParam("name")String name){
        Plate plates = getService.searchPlate(name);
        Map map = new HashMap();
        map.put("msg","这是含该字段的板块");
        map.put("plates",plates);
        map.put("status",1);
        return map;
    }
}
